package cfdt.ldl.web.system;


import cfdt.ldl.core.system.SystemConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import cfdt.tools.crypto.SecurityUtils;


/**
 * <pre>
 * Modify Information: 项目启动后自动执行的业务方法
 * Author       Date          Description
 * ============ ============= ============================
 * chenzhibin   2023年02月16日 Create this file
 * </pre>
 */
@Component
public class WebRunner implements ApplicationRunner {

    private final Logger logger = LoggerFactory.getLogger(getClass().getName());

    @Value("${business.secret}")
    private String secret;

    @Override
    public void run(ApplicationArguments args) {
        logger.info("进入项目自动启动加载方法....");
        System.out.println("进入项目自动启动加载方法....");

        try {
            // 密钥常量赋值
            SystemConstants.secret = SecurityUtils.decryptSM4(secret);

        } catch (Exception e) {
            logger.error("项目启动失败！", e);
            throw new RuntimeException(e);
        }

    }

}
